package org.light.generator;

import java.util.ArrayList;
import java.util.List;

import org.light.domain.Domain;
import org.light.domain.ManyToMany;

public class PrivilegedFacadesUrlGenerator {
	
	public static List<String> generatePrivilegedFacadesByDomains(List<Domain> domains,String privilegeName){
		List<String> urls = new ArrayList<String>();
		for (Domain d:domains) {
			if ("observer".equalsIgnoreCase(privilegeName)||"user".equalsIgnoreCase(privilegeName)|| "admin".equalsIgnoreCase(privilegeName)){
				urls.add("listAll"+d.getCapFirstPlural()+"Facade");
				urls.add("listAll"+d.getCapFirstPlural()+"ByPageFacade");
				urls.add("listActive"+d.getCapFirstPlural()+"Facade");
				urls.add("find"+d.getCapFirstDomainName()+"By"+d.getDomainId().getCapFirstFieldName()+"Facade");
				urls.add("find"+d.getCapFirstDomainName()+"By"+d.getDomainName().getCapFirstFieldName()+"Facade");
				urls.add("search"+d.getCapFirstPlural()+"By"+d.getDomainName().getCapFirstFieldName()+"Facade");
				urls.add("search"+d.getCapFirstPlural()+"By"+d.getDomainName().getCapFirstFieldName()+"Facade");
				urls.add("search"+d.getCapFirstPlural()+"ByFieldsByPageFacade");
			}
			if ("user".equalsIgnoreCase(privilegeName)|| "admin".equalsIgnoreCase(privilegeName)){
				urls.add("add"+d.getCapFirstDomainName()+"Facade");
				urls.add("delete"+d.getCapFirstDomainName()+"Facade");
				urls.add("softDelete"+d.getCapFirstDomainName()+"Facade");
				urls.add("toggle"+d.getCapFirstDomainName()+"Facade");
				urls.add("toggleOne"+d.getCapFirstDomainName()+"Facade");
				urls.add("update"+d.getCapFirstDomainName()+"Facade");
				urls.add("activate"+d.getCapFirstDomainName()+"Facade");
				urls.add("deleteAll"+d.getCapFirstPlural()+"Facade");
				urls.add("softDeleteAll"+d.getCapFirstPlural()+"Facade");
				urls.add("activateAll"+d.getCapFirstPlural()+"Facade");
			}
			
		}
		return urls;
		
	}
	public static List<String> generatePrivilegedFacadesByMtms(List<ManyToMany> mtms,String privilegeName){
		List<String> urls = new ArrayList<String>();
		for (ManyToMany mtm:mtms) {
			if ("observer".equalsIgnoreCase(privilegeName)||"user".equalsIgnoreCase(privilegeName)|| "admin".equalsIgnoreCase(privilegeName)){
				urls.add("listActive"+mtm.getMaster().getCapFirstPlural()+"Facade");
				urls.add("listActive"+mtm.getMaster().getCapFirstDomainName()+mtm.getSlave().getCapFirstPlural()+"Using"+mtm.getMaster().getCapFirstDomainName()+"IdFacade");
				urls.add("listAvailableActive"+mtm.getMaster().getCapFirstDomainName()+mtm.getSlave().getCapFirstPlural()+"Using"+mtm.getMaster().getCapFirstDomainName()+"IdFacade");
			}
			if ("user".equalsIgnoreCase(privilegeName)|| "admin".equalsIgnoreCase(privilegeName)){
				urls.add("assign"+mtm.getSlave().getCapFirstPlural()+"To"+mtm.getMaster().getCapFirstDomainName()+"Facade");
				urls.add("revoke"+mtm.getSlave().getCapFirstPlural()+"From"+mtm.getMaster().getCapFirstDomainName()+"Facade");
			}			
		}
		return urls;
		
	}
}
